Allow UDP to bind to the same ip/port#188
Merged
TrentHouliston merged 2 commits intomainfrom Aug 27, 2025
Merged
Conversation
Remove Duplicate int yes = 1
15939e0 to
81536ab
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR enables UDP sockets to bind to the same IP address and port combination by adding socket reuse options. The changes allow multiple UDP sockets to share the same address/port, which is useful for scenarios like load balancing or multiple listeners.
- Adds
SO_REUSEADDRandSO_REUSEPORTsocket options to UDP emit functionality - Removes conditional logic that previously restricted reuse options to only broadcast/multicast
- Removes duplicate broadcast socket option setting
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/dsl/word/emit/UDP.hpp | Adds socket reuse options and moves variable declaration to avoid duplication |
| src/dsl/word/UDP.hpp | Removes broadcast/multicast-only restriction for socket reuse options |
Comments suppressed due to low confidence (1)
src/dsl/word/UDP.hpp:210
- The variable
yesis being used but was not declared in this scope after removing the conditional block. The variable declaration needs to be added before this line.
if (::setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, reinterpret_cast<char*>(&yes), sizeof(yes)) < 0) {
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors how socket options are set for UDP sockets, improving consistency and reliability in both the main UDP implementation and the emit path. The changes focus on ensuring proper reuse of addresses and ports, and on clarifying when broadcast options are set.